<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('实训记录列表')" />
</head>
<body class="gray-bg">
<div class="ui-layout-center">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>实训学员：</label>
                                <input type="text" name="studentName"/>
                            </li>
                            <li>
                                <label>班级：</label>
                                <select name="roomId" id="roomId" th:with="type=${@common.getType('sys_room')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>所属课程：</label>
                                <select name="feeType" th:with="type=${@dict.getType('sys_fee_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>交费时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginFeeTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endFeeTime]"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="status" th:with="type=${@dict.getType('sys_train_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:train:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:train:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:train:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>

</div>
    <th:block th:include="include :: footer"/>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:train:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:train:remove')}]];
        var feeTypeDatas = [[${@dict.getType('sys_fee_type')}]];
        var isAdjustDatas = [[${@dict.getType('sys_yes_no')}]];
        var statusDatas = [[${@dict.getType('sys_train_status')}]];
        var storeDatas = [[${@common.getType('sys_store')}]];
        var prefix = ctx + "system/train";

        $(function () {
            queryStoreList();
        });

        function queryStoreList() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "收费记录",
                showFooter: true,//合计
                columns: [{
                    checkbox: true
                },
                {
                    field: 'trainId',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'student.studentName',
                    title: '实训学员',
                    footerFormatter: function (value) {
                        return '合计';
                    }
                },
                {
                    field: 'storeId',
                    title: '现实训门店',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(storeDatas, value);
                    }
                },
                {
                    field: 'feeType',
                    title: '费用类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(feeTypeDatas, value);
                    }
                },
                {
                    field: 'feeTime',
                    title: '交费时间'
                },
                {
                    field: 'money',
                    title: '金额',
                    footerFormatter: function (value) {
                        var count = 0;
                        for (var i in value) { count += value[i].money; }
                        return count.toFixed(2);
                    }
                },
                {
                    field: 'comeTime',
                    title: '到店时间'
                },
                {
                    field: 'isAdjust',
                    title: '是否调店',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(isAdjustDatas, value);
                    }
                },
                {
                    field: 'adjustTime',
                    title: '调店时间'
                },
                {
                    field: 'oldStoreId',
                    title: '原实训门店',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(storeDatas, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    field: 'lostTime',
                    title: '流失时间'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.trainId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.trainId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        }
    </script>
</body>
</html>